package com.wxg.demo;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import com.wxg.utils.My;
import com.wxg.utils.MyDriver;

public class ParagraphSplit101 {

	public static void main(String[] args) {
		code102();
	}
	
	/**
	 * @see com.wxg.demo.ElementHeight102 : code105
	 * @see com.wxg.demo.HtmlSplit101 : code103
	 * 
	 * 
	 */
	public static void code102(){
		WebDriver driver = MyDriver.getStaticDriver();
		List<WebElement> eleList = null;
		
		String strUrl = My.fileUrl("F:\\wxg\\for_print\\html\\html104.html");
		
		driver.get( strUrl );
		eleList = driver.findElements(By.tagName("p"));
		if(null != eleList){
			System.out.println( eleList.size() );
			for(WebElement ele : eleList){
//				System.out.println( ele.getText() );
//				ele.clear(); // "errorMessage":"Element must be user-editable in order to clear it."
//				System.out.println( ele.getAttribute("outerHTML") );
				
			}
		}
		
		
		// driver quit
		MyDriver.closeStaticDriver();
	}
	
	public static void code101(){
		WebDriver driver = MyDriver.getStaticDriver();
		List<WebElement> eleList = null;
		
		String strUrl = My.fileUrl("F:\\wxg\\for_print\\html\\html104.html");
		
		driver.get( strUrl );
		eleList = driver.findElements(By.tagName("p"));
		if(null != eleList){
			System.out.println( eleList.size() );
			for(WebElement ele : eleList){
				Point point = ele.getLocation();
				Dimension dimension = ele.getSize();
				System.out.printf("\nx: %s, y: %s, width: %s, height: %s\n", point.x, point.y, dimension.width, dimension.height);
				String outHtml = ele.getAttribute("outerHTML");
				System.out.printf( "\n outerHTML: %s \n", outHtml );
				String text = ele.getText();
				System.out.printf( "\n text: %s \n", text );
			}
		}
		
		MyDriver.closeStaticDriver();
		
	}
	
}
